import operate from '@dfeidao/atom-nodejs/db/operate';
// import sys_date from '@dfeidao/atom-nodejs/msg/sys-date';
// import whoami from '@dfeidao/atom-web/msg/whoami';


interface Message {
	// wk: {
	// 	_id: string,
	// 	password: string
	// }[];
	wk: Array<{
		_id: string,
		password: string
	}>;
}
export default async function atom(msg: Message, action_id: string, session_id: string, spaceid: string) {
	// const user = await whoami();
	const systemid = '12';
	const { exec, update } = operate(action_id, session_id, systemid);
	Array.from(msg.wk).forEach((v) => {
		update('pub_user', { _id: v._id }, v);
	});
	// debugger
	const ret = await exec();
	if (ret.code === 1) {
		return 'success';
	} else {
		return 'fail';
	}
}
